package com.sumainfor.pc.epc.controller;

import com.sumainfor.common.util.FieldCheckUtil;
import com.sumainfor.common.util.JsonResult;
import com.sumainfor.common.utlis.PageUtils;
import com.sumainfor.common.utlis.Pager;
import com.sumainfor.pc.epc.dao.ManagerWorkbenchMapper;
import com.sumainfor.pc.epc.feign.Zfeign.ZzuulFeign;
import com.sumainfor.pc.epc.service.ManagerWorkbenchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 工程经理（工作台）
 * <p>
 *
 * @author: zhoucong
 * @create: 2019-04-09 14:05
 **/
@Controller
@RequestMapping("/managerWorkbench")
public class ManagerWorkbenchController {


    @Autowired
    ManagerWorkbenchService managerWorkbenchService;

    @Autowired
    ManagerWorkbenchMapper managerWorkbenchMapper;

    @Autowired
    ZzuulFeign zzuulFeign;


    /**
    * <p>
    * 重要状态提醒
    * </p>
    *
    * @author: zhoucong
    * @since:
    */
    @ResponseBody
    @GetMapping("/importantState")
    public JsonResult importantState(){

        return managerWorkbenchService.importantState();
    }

    /**
     * <p>
     * 系统消息提醒
     * </p>
     *
     * @author: zhoucong
     * @since:
     */
    @ResponseBody
    @GetMapping("/systemMessage")
    public JsonResult systemMessage(@RequestParam Map<String,Object> params, Pager pager){
        System.out.println("asd"+params);
        JsonResult result = new JsonResult();
        if(!FieldCheckUtil.isMapFieldNotNull(params ,new String[]{"MeType"})){
            return  result.putFailed("消息角色不能为空...");
        }
        return zzuulFeign.getMessageList(params,pager);


    }

    /**
    * <p>
    * 采购进度
    * </p>
    *
    * @author: zhoucong
    * @since:
    */
    @ResponseBody
    @GetMapping("/purchasingSchedule")
    public JsonResult purchasingSchedule(){
        return managerWorkbenchService.purchasingSchedule();
    }


    /**
    * <p>
    * 装修进度
    * </p>
    *
    * @author: zhoucong
    * @since:
    */
    @ResponseBody
    @GetMapping("/decorateProgress")
     public JsonResult decorateProgress(){
        return managerWorkbenchService.decorateProgress();
    }

    /**
    * <p>
    * 供应商管理
    * </p>
    *
    * @author: zhoucong
    * @since:
    */
    @ResponseBody
    @GetMapping("/supplierManagement")
    public JsonResult supplierManagement(){
        return managerWorkbenchService.supplierManagement();
    }


    /**
    * <p>
    * 查找全部，月，季度，年的维修单情况
    * </p>
    *
    * @author: zhoucong
    * @since:
    */
    @ResponseBody
    @GetMapping("/getMaintenanceStatus")
    public JsonResult getMaintenanceStatus(@RequestParam Map<String,Object> params){
        JsonResult result = new JsonResult();
        if(!FieldCheckUtil.isMapFieldNotNull(params ,new String[]{"State"})){
            return  result.putFailed("服务器繁忙...");
        }
        return managerWorkbenchService.getMaintenanceStatus(params);
    }

    /**
    * <p>
    * 本月个人维修单数及其好评率情况
    * </p>
    *
    * @author: zhoucong
    * @since:
    */
    @ResponseBody
    @GetMapping("/maintenanceRating")
    public JsonResult maintenanceRating(){
        return managerWorkbenchService.getRepairLists();

    }


}
